<template>
	<view class="create-page">
		<view class="moment-save" v-if="saveAct.length!=0">
			<text>你有暂存活动，还未发布，是否去查看</text>
			<view class="" @click="checkAct">
				立即查看
			</view>
		</view>
		<view class="special-group">
			<view class="group-share">
				<view class="group-share-img">
					<image :src="imglink + 'member/create-active_icon_code.svg'" mode=""></image>
					<view class="group-share-content">
						<view class="">创建活动收款码</view>
						<view class="">上传海报就创建收款码</view>
					</view>
				</view>
				<view class="group-share-make" @click="makeGroup('addcollectioncode')">
					马上制作
				</view>
			</view>
			<view class="group-share" style="margin-top: 20upx;">
				<view class="group-share-img">
					<image :src="imglink + 'member/create-active_icon_group.svg'" mode=""></image>
					<view class="group-share-content">
						<view class="">团购拼单</view>
						<view class="">支持1个和多个课程拼团裂变</view>
					</view>
				</view>
				<view class="group-share-make" @click="makeGroup('group')">
					马上制作
				</view>
			</view>
			<view class="group-share" style="margin-top: 20upx;">
				<view class="group-share-img">
					<image :src="imglink + 'member/create-active_icon_prefer.svg'" mode=""></image>
					<view class="group-share-content">
						<view class="">特价优惠</view>
						<view class="">支持1个和多个课程特价优惠</view>
					</view>
				</view>
				<view class="group-share-make" @click="makeGroup('discounts')">
					马上制作
				</view>
			</view>

			<!-- 支付重定向跳转页面 -->
			<!-- <button type="default" @click="toRedirect">支付重定向页面</button> -->
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				imglink: this.$store.state.imgLink,
				saveAct: [],
				store_id: ''
			}
		},
		onLoad(options) {
			let store_id = parseInt(options.store_id, 10);
			if (!store_id > 0) {
				store_id = uni.getStorageSync('store_id')
			} else {
				uni.setStorageSync('store_id', store_id)
			}
			this.store_id = store_id
			this.$store.commit('updateStoreId', store_id)
		},
		onShow() {
			this.getActList()
			this.$store.state.actForm = null
		},
		methods: {
			// 获取所有活动信息
			getActList() {
				let data = {
					store_id: this.$store.getters.getStoreId,
				}
				this.$api.gain_all_act(data).then(res => {
					console.log(res)
					if (res.status) {
						res.list.data.forEach(item => {
							if (item.operate_status == 0) {
								this.saveAct.push(item)
							}
						})
						console.log(this.saveAct, '暂存活动列表')
					} else {
						uni.showToast({
							title: res.msg,
							icon: "none",
							duration: 2000
						})
					}
				}).catch(err => {
					console.log(err)
				})
			},
			checkAct() {
				uni.navigateTo({
					url: '../activityManage/activityManage?topNavActiveIndex=2?&store_id=' + this.store_id
				})
			},
			makeGroup(flag) {
				this.$store.state.actForm = null
				if (flag == 'group') {
					uni.navigateTo({
						url: '../specialGroup/specialGroup?page=add&type=' + flag + '&store_id=' + this.store_id
					})
				} else if (flag == 'discounts') {
					uni.navigateTo({
						url: '../specialGroup/specialGroup?page=add&type=' + flag + '&store_id=' + this.store_id
					})
				} else if (flag == 'addcollectioncode') {
					uni.navigateTo({
						url: '../collectioncode/addcollectioncode?store_id=' + this.store_id
					})
				}

			},
			toRedirect() {
				console.log('点击了', uni.getStorageSync('redirectUrl'));
				let redirectUrl = '/pages/home/order/orderMsg?store_id=' 
				uni.setStorageSync('redirectUrl', redirectUrl)
				uni.navigateTo({
					url: '../../home/order/payPageRedirect'
				})
				// uni.navigateTo({
				// 	// url:'pages/memberCenter/collectioncode/collectioncode/registrationsuccessful'
				// 	url:'../collectioncode/collectioncode/registrationsuccessful'
				// 	// url:'../collectioncode/collectioncode/collectioncode/registrationsuccessful'
				// })

			}
		}
	}
</script>

<style scoped>
	page {
		background: #F3F3F4;
	}

	.create-page {
		width: 100%;
	}

	.moment-save {
		width: 100%;
		padding: 10upx 94upx;
		box-sizing: border-box;
		display: flex;
		background: #FFF7D8;
	}

	.moment-save>text {
		color: #666666;
		font-size: 24upx;
		margin-top: 4upx;
	}

	.moment-save>view {
		width: 128upx;
		line-height: 38upx;
		text-align: center;
		border: 2upx solid #FF8B46;
		color: #FF8B46;
		font-size: 24upx;
		margin-left: 20upx;
	}

	.special-group {
		width: 100%;
		padding: 0 30upx;
		box-sizing: border-box;
		margin-top: 20upx;
	}

	.group-share {
		width: 100%;
		padding: 46upx 20upx;
		box-sizing: border-box;
		display: flex;
		justify-content: space-between;
		border-radius: 8upx;
		background: #FFFFFF;
	}

	.group-share-img {
		display: flex;
		justify-content: space-between;
	}

	.group-share-img>image {
		width: 80upx;
		height: 80upx;
		margin-right: 20upx;
	}

	.group-share-content>view:first-child {
		color: #333333;
		font-size: 34upx;
	}

	.group-share-content>view:last-child {
		color: #999999;
		font-size: 24upx;
		margin-top: 4upx;
	}

	.group-share-make {
		width: 180upx;
		height: 60upx;
		line-height: 60upx;
		background: linear-gradient(to right, #FE9543, #FF664F);
		border-radius: 4upx;
		box-shadow: 0 8upx 16upx 0 rgba(225, 49, 0, 0.23);
		color: #FFFFFF;
		font-size: 30upx;
		text-align: center;
	}
</style>
